// 1.先引入样式重置表
require('../../assets/css/index.js');
// 引入字体图标
require('../../assets/iconfonts/iconfont.css');
//2.引入当前页面样式
require('./first.less');
// 3.辅助类功具函数
let dom = require('../../utils/dom');
let http = require('../../utils/http');
let Swiper= require('../../utils/swiper-bundle.min');

http.getygc();
// 4.当前页面的js文件
dom.ready(function () {
    var mySwiper = new Swiper ('.swiper-container', {
        loop: true, // 循环模式选项
        autoplay:true,
        // 如果需要分页器
        pagination: {
          el: '.swiper-pagination',
        },
      })      
      
      dom.Foot('home')

      getuserInfo()


      // 解构赋值
      
      function getuserInfo() {
        http.get("/api/user/info",{},function(res){
          if(res.errno==0) {
            let {ranking,clockCount,badges}=res.data;
            rankingnum.innerText=ranking
            clockCountnum.innerText=clockCount
            badgesnum.innerText=badges
          }
        })
      }
      
      dk() 

      // 获取打卡
      function dk() {
        http.get("/api/user/clockInInfo",{},function(res){
          if(res.errno==0){
            let {isClockIn}=res.data
            jrdk.innerText = isClockIn?"打卡成功":"今日打卡"
          }
        })
      }

      dom.getEl("#jrdk").addEventListener("click",function(){
        http.post("/api/user/clockIn",{},function(res){
          if(res.errno==0){
            dk();
          }else{
            weui.topTips('今日已经打卡');
          }
        })
      })
})